#!/bin/bash

# 将当前目录设置为 scriptPATH
scriptPATH=$(cd $(dirname $0);pwd)

get_info(){
    date=`   /bin/bash $scriptPATH/dwm.data.sh`    # 时间
    battery=`/bin/bash $scriptPATH/dwm.battery.sh` # 电池电量
    light=`  /bin/bash $scriptPATH/dwm.light.sh`   # 屏幕亮度
    volume=` /bin/bash $scriptPATH/dwm.volume.sh`  # 音量
    cpu=`    /bin/bash $scriptPATH/dwm.cpu.sh`     # cpu 占用率
    network=`/bin/bash $scriptPATH/dwm.network.sh` # 网络速率
    other=`  /bin/bash $scriptPATH/dwm.other.sh`   # 其他显示 (docker clash\蓝牙)
}

while true
do
    [ "${MY_LOCK}" != "$0"  ] && exec env MY_LOCK="$0" flock -xn "$0" "$0" "$@"

    get_info

    #xsetroot -name "[$network] [$cpu] [$volume] [$light] [$battery] [$date]"
    #xsetroot -name "[$other] [$network] [$volume] [$battery] [$date]"
    xsetroot -name " $other | $network | $volume | $battery | $date |"
    sleep 1s
done
